<?php declare(strict_types=1);
/**
 * @author      xianganyall <xianganyall@gmail.com>
 * @copyright   2023-2025 owner
 **/

namespace Srv\Apps\Apis\Common\IdxCtl;

final class IdxIdfaCtl extends IdxAbstract
{
    private const TABLE_NAME                = 'idx_idfa';
    private const FIELD_ID                  = 'idfa_id';
    private const FIELD_VAL                 = 'idfa_val';
    private const FIELD_FRONT_NUM           = 'idfa_front_md5_num';
    private const FIELD_BACK_NUM            = 'idfa_back_md5_num';

    /**
     * @return static
     * tag
     */
    public static function tag():self
    {
        return parent::tag()->config(self::TABLE_NAME, self::FIELD_ID, self::FIELD_VAL, self::FIELD_FRONT_NUM, self::FIELD_BACK_NUM);
    }

    /**
     * @param string $val
     * @param string $frontNumStr
     * @param string $backNumStr
     * @return int
     * getIdByValCreate
     */
    public function getIdByValCreate(string $val, string &$frontNumStr = '', string &$backNumStr = ''):int
    {
        if(preg_match('/^[0\-]+$/', $val) > 0 || preg_match('/^[F\-]+$/i', $val) > 0 || preg_match('/^[1\-]+$/', $val) > 0 || preg_match('/^[2\-]+$/', $val) > 0 || preg_match('/^[3\-]+$/', $val) > 0 || preg_match('/^[4\-]+$/', $val) > 0 || preg_match('/^[5\-]+$/', $val) > 0 || preg_match('/^[6\-]+$/', $val) > 0 || preg_match('/^[7\-]+$/', $val) > 0 || preg_match('/^[8\-]+$/', $val) > 0 || preg_match('/^[9\-]+$/', $val) > 0 || preg_match('/^[A\-]+$/i', $val) > 0 || preg_match('/^[B\-]+$/i', $val) > 0 || preg_match('/^[C\-]+$/i', $val) > 0 || preg_match('/^[D\-]+$/i', $val) > 0 || preg_match('/^[E\-]+$/i', $val) > 0) return 0;
        return parent::getIdByValCreate($val, $frontNumStr, $backNumStr);
    }
}